﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Baosight.ZNH.ZMCommon;
using Baosight.Platform.Core;
using Telerik.Windows.Controls;
using Baosight.ZNH.ZMCB.UI.PopWindows;
using Baosight.ZNH.ZMCommon.ChildWindows;
using Baosight.Platform.Core.ServiceModel;
using Baosight.Platform.Core.UI.Controls;


namespace Baosight.ZNH.ZMCB.UI
{
    /// <summary>
    /// 编制防突年计划
    /// </summary>
    /// Copyright:Baosight Software LTD.co Copyright (c) 2011
    /// Company:上海宝信软件股份有限公司
    /// Author: 梁琦
    /// Version: 1.0
    /// History:
    ///       2013-07-08  梁琦   [创建]
    ///
    public partial class ZMCB50 : EFViewCmes
    {
        String year;
        String status;
        String ForeignId;
        public ZMCB50()
        {
            InitializeComponent();
            base.BeforeAction += OnBeforeAction;
        }

        /// <summary>
        /// 列表中修改、删除前设置属性、参数
        /// 传递到后台代码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnBeforeAction(object sender, EventArgs e)
        {
            EFViewCmesProperty _view = new EFViewCmesProperty();
            base.ViewProperty = _view;
        }

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="initData"></param>
        public override void Initialize(EIInfo initData)
        {

            year = (string)initData.Get("year");
            status = (string)initData.Get("status");
            ForeignId = (string)initData.Get("ForeignId");
            this.titleText.Text =year+"年防突计划";
            this.StatusText.Text = "计划状态：" + status;
            this.fdYear.Value = year;
            base.Initialize(initData);
            Dictionary<string, string> args = new Dictionary<string, string>();
            args.Add("fdYear", year);
            args.Add("fdStatus", status);
            args.Add("fdForeignId", ForeignId);
            this.container.LoadView("ZMCB51", args);
        }


        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void OnQueryButtonClick(object sender, RoutedEventArgs e)
        {
           
            Submit(OperationMode.Query, "ZMCB40", "query", DataRange.All, queryCompleted);
            
        }
        private void queryCompleted(object sender, DoWorkCompletedEventArgs e)
        {
            year = (string)e.EIInfo.Get("year");
            status = (string)e.EIInfo.Get("status");
            ForeignId = (string)e.EIInfo.Get("ForeignId");
            this.titleText.Text = year + "年防突计划";
            this.StatusText.Text = "计划状态：" + status;
            Dictionary<string, string> args = new Dictionary<string, string>();
            args.Add("fdYear", year);
            args.Add("fdStatus", status);
            args.Add("fdForeignId", ForeignId);
            this.container.LoadView("ZMCB51", args);
        }

        /// <summary>
        /// 重新基类的方法，当有新的EIInfo 数据发布时回调的方法
        /// 生产进度新增修改后更新统计数据
        /// </summary>
        /// <param name="data"></param>
        public override void OnEIDataPublished(EIInfo data)
        {
            //刷新页面
            if (this.StatusText.Text == "计划状态：无计划")
            {
                Submit(OperationMode.Query, "ZMCB40", "query", DataRange.All, queryCompleted);
            }
        }

    }
}

